<template>
  <div class="homepage">
    <!-- 搜索框 -->
    <div class="serchbox">
      <DropDownOptions
        :options="selectdownList"
        :placeholder="placeHolder"
        @blur="selectdownFuc"
      />
      <el-button type="primary" icon="el-icon-search" @click="search"
        >搜索</el-button
      >
    </div>
    <!-- 余额板块 -->
    <div class="balance">
      <div class="balance-box" v-for="item in recharge" :key="item.id">
        <div class="balance-box-title">
          <div class="balance-box-title-text">
            {{ item.name }}
          </div>
          <span class="balance-box-title-yuan">
            <p v-if="item.name == '昨日代付总笔数'">笔</p>
            <p v-else>元</p>
          </span>
        </div>
        <div class="balance-box-money">
          <p>{{ item.money }}</p>
        </div>
      </div>
    </div>

    <!-- 图表 -->
    <div class="echars">
      <div id="myChart" :style="{ width: '100%', height: '400px' }"></div>
    </div>
  </div>
</template>

<script>
import DropDownOptions from "../../components/MerchantManagement/BusinessListings/DropDownOptions.vue";
export default {
  name: "HomePage",
  data() {
    return {
      massage: "首页",
      placeHolder: "商户",
      selectdownList: [
        {
          value: "选项1",
          label: "黄金糕111",
        },
        {
          value: "选项2",
          label: "双皮奶",
        },
        {
          value: "选项3",
          label: "蚵仔煎",
        },
        {
          value: "选项4",
          label: "龙须面",
        },
        {
          value: "选项5",
          label: "北京烤鸭",
        },
      ],
      recharge: [
        {
          id: 1,
          name: "今日总充值金额",
          money: " 40124",
        },
        {
          id: 2,
          name: "今日总充值手续费",
          money: " 0",
        },
        {
          id: 3,
          name: "今日代付总金额",
          money: " 0",
        },
        {
          id: 4,
          name: "今日代付总笔数",
          money: " 0",
        },
        {
          id: 5,
          name: "今日代付总手续费",
          money: " 0",
        },
        {
          id: 6,
          name: "今日盈利",
          money: " 11111111",
        },
        {
          id: 7,
          name: "昨日总充值金额",
          money: " 11122222",
        },
        {
          id: 8,
          name: "昨日总充值手续费",
          money: " 0",
        },
        {
          id: 9,
          name: "昨日代付总金额",
          money: " 5832",
        },
        {
          id: 10,
          name: "昨日代付总笔数",
          money: " 1",
        },
        {
          id: 11,
          name: "昨日代付总手续费",
          money: " 16999",
        },
        {
          id: 12,
          name: "昨日盈利",
          money: " 16999",
        },
      ],
      searchbox: "",
    };
  },
  mounted() {
    /*初始化ECharts图表，绑定到id=myChart的div上面*/
    var myChart = this.$echarts.init(document.getElementById("myChart"));
    myChart.setOption({
      title: {
        text: "代付业务统计图",
      },
      tooltip: {
        trigger: "axis",
      },
      legend: {
        data: ["充值金额", "充值手续费", "代付金额", "代付笔数", "代付手续费"],
      },
      grid: {
        left: "3%",
        right: "4%",
        bottom: "3%",
        containLabel: true,
      },
      toolbox: {
        feature: {
          saveAsImage: {},
        },
      },
      xAxis: {
        type: "category",
        boundaryGap: false,
        data: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],//时间
      },
      yAxis: {
        type: "value",
      },
      series: [
        {
          name: "充值金额",
          type: "line",
          stack: "Total",
          data: [120, 132, 101, 134, 90, 230, 210],//七天内的数据
        },
        {
          name: "充值手续费",
          type: "line",
          stack: "Total",
          data: [220, 182, 191, 234, 290, 330, 310],
        },
        {
          name: "代付金额",
          type: "line",
          stack: "Total",
          data: [150, 232, 201, 154, 190, 330, 410],
        },
        {
          name: "代付笔数",
          type: "line",
          stack: "Total",
          data: [320, 332, 301, 334, 390, 330, 320],
        },
        {
          name: "代付手续费",
          type: "line",
          stack: "Total",
          data: [820, 932, 901, 934, 1290, 1330, 1320],
        },
      ],
    });
  },
  components: { DropDownOptions },
  methods: {
    selectdownFuc(v) {
      this.searchbox = v;
      console.log(this.searchbox);
    },
    search() {
      if (this.searchbox == "") {
        return;
      } else {
        const ser = this.searchbox;
        this.searchbox = "";
        console.log(ser);
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.homepage {
  padding: 15px;
  background: white;
}
.serchbox {
  padding: 15px 0;
  border-bottom: 1px solid gray;
}
.el-button{
  margin-left:15px;
}
.balance {
  display: flex;
  flex-wrap: wrap;
  margin-top: 15px;
  justify-content: space-evenly;
}
.balance-box {
  margin: 35px;
  width: 190px;
  height: 130px;
  background-color: #fff;
  border: 1px solid gainsboro;
  border-radius: 5px;
  box-shadow: 10px 5px 10px gainsboro;
}
.balance-box-title {
  height: 42px;
  line-height: 42px;
  padding: 0 15px;
  border-bottom: 1px solid #f6f6f6;
  color: #333;
  border-radius: 2px 2px 0 0;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
}
.balance-box-title-yuan {
  width: 24px;
  height: 20px;
  padding: 0 6px;
  background-color: #393d49;
  border-radius: 2px;
  font-size: 14px;
  color: #fff;
  box-sizing: border-box;
  text-align: center;
  line-height: 20px;
  margin-top: 10px;
}
.balance-box-money {
  color: #666;
  text-align: left;
  padding: 10px 15px;
  line-height: 24px;
}
.balance-box-money p {
  font-size: 36px;
  line-height: 36px;
  padding: 5px 0 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
}
.charts-title {
  color: #666;
  font-size: 20px;
}
.echars {
  height: 450px;
}
</style>